<!DOCTYPE html>
<html lang="en">
<head>
    <title>catpl demo</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <script src="../src/catpl.js"></script>
</head>
<body>
<div id="content"></div>

<script id="test" type="text/html">
    <h1>{{title}}</h1>
    <ul>
        {{foreach sports as value i}}
        <li class="{{if i===index}}active{{/if}}">{{i+1}} - {{value.name}}</li>
        {{/foreach}}
    </ul>
</script>

<script>
    var data = {
        title: '你喜爱的运动',
        sports: [
            {name: '足球'},
            {name: '篮球'},
            {name: '乒乓球'}
        ],
        index: 1
    };

    var render = catpl('test');
    var html = render(data);
    document.getElementById('content').innerHTML = html;
</script>
</body>
</html>